\(\int \frac {A+B \cos (x)}{1-\sin (x)} \, dx\) [3]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 15, antiderivative size = 23 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=-B \log (1-\sin (x))+\frac {A \cos (x)}{1-\sin (x)} \]

[Out]

-B*ln(1-sin(x))+A*cos(x)/(1-sin(x))

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 23, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.267, Rules used = {4486, 2727, 2746, 31} \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=\frac {A \cos (x)}{1-\sin (x)}-B \log (1-\sin (x)) \]

[In]

Int[(A + B*Cos[x])/(1 - Sin[x]),x]

[Out]

-(B*Log[1 - Sin[x]]) + (A*Cos[x])/(1 - Sin[x])

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rule 2727

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Simp[-Cos[c + d*x]/(d*(b + a*Sin[c + d*x])), x]
/; FreeQ[{a, b, c, d}, x] && EqQ[a^2 - b^2, 0]

Rule 2746

Int[cos[(e_.) + (f_.)*(x_)]^(p_.)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(b^p*f), S
ubst[Int[(a + x)^(m + (p - 1)/2)*(a - x)^((p - 1)/2), x], x, b*Sin[e + f*x]], x] /; FreeQ[{a, b, e, f, m}, x]
&& IntegerQ[(p - 1)/2] && EqQ[a^2 - b^2, 0] && (GeQ[p, -1] ||  !IntegerQ[m + 1/2])

Rule 4486

Int[u_, x_Symbol] :> With[{v = ExpandTrig[u, x]}, Int[v, x] /; SumQ[v]] /;  !InertTrigFreeQ[u]

Rubi steps \begin{align*} \text {integral}& = \int \left (-\frac {A}{-1+\sin (x)}-\frac {B \cos (x)}{-1+\sin (x)}\right ) \, dx \\ & = -\left (A \int \frac {1}{-1+\sin (x)} \, dx\right )-B \int \frac {\cos (x)}{-1+\sin (x)} \, dx \\ & = \frac {A \cos (x)}{1-\sin (x)}-B \text {Subst}\left (\int \frac {1}{-1+x} \, dx,x,\sin (x)\right ) \\ & = -B \log (1-\sin (x))+\frac {A \cos (x)}{1-\sin (x)} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.11 (sec) , antiderivative size = 46, normalized size of antiderivative = 2.00 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=-2 B \log \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )+\frac {2 A \sin \left (\frac {x}{2}\right )}{\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )} \]

[In]

Integrate[(A + B*Cos[x])/(1 - Sin[x]),x]

[Out]

-2*B*Log[Cos[x/2] - Sin[x/2]] + (2*A*Sin[x/2])/(Cos[x/2] - Sin[x/2])

Maple [A] (verified)

Time = 0.91 (sec) , antiderivative size = 23, normalized size of antiderivative = 1.00

method result size
parts \(-\frac {2 A}{\tan \left (\frac {x}{2}\right )-1}-B \ln \left (1-\sin \left (x \right )\right )\) \(23\)
risch \(i x B +\frac {2 A}{{\mathrm e}^{i x}-i}-2 B \ln \left ({\mathrm e}^{i x}-i\right )\) \(32\)
parallelrisch \(B \ln \left (\frac {2}{\cos \left (x \right )+1}\right )-2 B \ln \left (-\cot \left (x \right )+\csc \left (x \right )-1\right )+A \left (\sec \left (x \right )+\tan \left (x \right )+1\right )\) \(33\)
default \(-\frac {2 A}{\tan \left (\frac {x}{2}\right )-1}-2 B \ln \left (\tan \left (\frac {x}{2}\right )-1\right )+B \ln \left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )\) \(34\)
norman \(\frac {-2 A \left (\tan ^{2}\left (\frac {x}{2}\right )\right )-2 A}{\left (1+\tan ^{2}\left (\frac {x}{2}\right )\right ) \left (\tan \left (\frac {x}{2}\right )-1\right )}+B \ln \left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )-2 B \ln \left (\tan \left (\frac {x}{2}\right )-1\right )\) \(55\)

[In]

int((A+B*cos(x))/(1-sin(x)),x,method=_RETURNVERBOSE)

[Out]

-2*A/(tan(1/2*x)-1)-B*ln(1-sin(x))

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 41, normalized size of antiderivative = 1.78 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=\frac {A \cos \left (x\right ) - {\left (B \cos \left (x\right ) - B \sin \left (x\right ) + B\right )} \log \left (-\sin \left (x\right ) + 1\right ) + A \sin \left (x\right ) + A}{\cos \left (x\right ) - \sin \left (x\right ) + 1} \]

[In]

integrate((A+B*cos(x))/(1-sin(x)),x, algorithm="fricas")

[Out]

(A*cos(x) - (B*cos(x) - B*sin(x) + B)*log(-sin(x) + 1) + A*sin(x) + A)/(cos(x) - sin(x) + 1)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 94 vs. \(2 (17) = 34\).

Time = 0.34 (sec) , antiderivative size = 94, normalized size of antiderivative = 4.09 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=- \frac {2 A}{\tan {\left (\frac {x}{2} \right )} - 1} - \frac {2 B \log {\left (\tan {\left (\frac {x}{2} \right )} - 1 \right )} \tan {\left (\frac {x}{2} \right )}}{\tan {\left (\frac {x}{2} \right )} - 1} + \frac {2 B \log {\left (\tan {\left (\frac {x}{2} \right )} - 1 \right )}}{\tan {\left (\frac {x}{2} \right )} - 1} + \frac {B \log {\left (\tan ^{2}{\left (\frac {x}{2} \right )} + 1 \right )} \tan {\left (\frac {x}{2} \right )}}{\tan {\left (\frac {x}{2} \right )} - 1} - \frac {B \log {\left (\tan ^{2}{\left (\frac {x}{2} \right )} + 1 \right )}}{\tan {\left (\frac {x}{2} \right )} - 1} \]

[In]

integrate((A+B*cos(x))/(1-sin(x)),x)

[Out]

-2*A/(tan(x/2) - 1) - 2*B*log(tan(x/2) - 1)*tan(x/2)/(tan(x/2) - 1) + 2*B*log(tan(x/2) - 1)/(tan(x/2) - 1) + B
*log(tan(x/2)**2 + 1)*tan(x/2)/(tan(x/2) - 1) - B*log(tan(x/2)**2 + 1)/(tan(x/2) - 1)

Maxima [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.09 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=-B \log \left (\sin \left (x\right ) - 1\right ) - \frac {2 \, A}{\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1} - 1} \]

[In]

integrate((A+B*cos(x))/(1-sin(x)),x, algorithm="maxima")

[Out]

-B*log(sin(x) - 1) - 2*A/(sin(x)/(cos(x) + 1) - 1)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 46 vs. \(2 (22) = 44\).

Time = 0.31 (sec) , antiderivative size = 46, normalized size of antiderivative = 2.00 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=B \log \left (\tan \left (\frac {1}{2} \, x\right )^{2} + 1\right ) - 2 \, B \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) - 1 \right |}\right ) + \frac {2 \, {\left (B \tan \left (\frac {1}{2} \, x\right ) - A - B\right )}}{\tan \left (\frac {1}{2} \, x\right ) - 1} \]

[In]

integrate((A+B*cos(x))/(1-sin(x)),x, algorithm="giac")

[Out]

B*log(tan(1/2*x)^2 + 1) - 2*B*log(abs(tan(1/2*x) - 1)) + 2*(B*tan(1/2*x) - A - B)/(tan(1/2*x) - 1)

Mupad [B] (verification not implemented)

Time = 14.74 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.43 \[ \int \frac {A+B \cos (x)}{1-\sin (x)} \, dx=B\,\ln \left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )-\frac {2\,A}{\mathrm {tan}\left (\frac {x}{2}\right )-1}-2\,B\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )-1\right ) \]

[In]

int(-(A + B*cos(x))/(sin(x) - 1),x)

[Out]

B*log(tan(x/2)^2 + 1) - (2*A)/(tan(x/2) - 1) - 2*B*log(tan(x/2) - 1)